from django.db import models
from user.models import UserModel
from goods.models import ProductModel
# Create your models here.

class CartModel(models.Model):
    user = models.ForeignKey(UserModel, on_delete=models.CASCADE, verbose_name="关联的用户")
    created_at = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    product = models.ForeignKey(ProductModel, on_delete=models.CASCADE, verbose_name="商品")

    def __str__(self):
        return f"{self.user} 的购物车 - {self.created_at}"

    class Meta:
        db_table = "cart"
        verbose_name = "购物车表"
        verbose_name_plural = "购物车表"

 